﻿#define _CRT_SECURE_NO_WARNINGS

//命名空间的使用有三种方式：
//1.加命名空间名称及作用域限定符
//2.使用using将命名空间中某个成员引入
//3.使用using namespace 命名空间名称 引入


/*
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    //不使用命名空间需要加std::
    char ch = 0;
    std::cout << "Hello World!\n" << std::endl;
    std::cin >>ch;
    std::cout <<"ch = " << ch << "\n" << std::endl;
    //使用缺省的命名空间则可以省略std::
    int i = 5;
    cout << "请输入i的数值" << endl;
    cin >> i;
    cout << "i = "<<i<<"\n" << endl;
    cout << "Hello World!\n"<<endl;
    cout << "Hello bite!\n" << endl;
    cout << "XXXXXXXXXXX\n" << endl;
}
*/

/*
#include<iostream>
using namespace std;
namespace N1
{
    int a = 5, b = 8;
    int Add(int left, int right)
    {
        return left + right;
    }
}
namespace N2                                 //命名空间嵌套
{
    int x = 6, y = 9;
    int Sub(int left, int right)
    {
        return left - right;
    }
    namespace N3
    {
        int vx = 8, vy = 9;
        int Mul(int left, int right)
        {
            return left * right;
        }
    }
}

int Q = 8;                 //1.加命名空间名称及作用域限定符
using N1::a;               //2.使用using将命名空间中某个成员引入
using namespace N1;        //3.使用using namespace 命名空间名称引入

int main()
{
    cout << "::Q = " << ::Q << endl;                     //1.作用域限定符::访问全局变量
    cout << "a = " << a << endl;                         //2.使用using将命名空间中某个成员引入
    cout << "N1::a = " << N1::a << endl;                 //3.使用using namespace 命名空间名称引入

    cout << "N1::a = " << N1::a << endl;
    cout << "N1::b = " << N1::b << endl;
    cout << "N1::Add(3, 6) = " << N1::Add(3, 6) << endl;

    cout << "N2::x = " << N2::x << endl;
    cout << "N2::y = " << N2::y << endl;
    cout << "N2::Sub(6, 3) = " << N2::Sub(6, 3) << endl;

    cout << "N2::N3::vx = " << N2::N3::vx << endl;
    cout << "N2::N3::vy = " << N2::N3::vy << endl;
    cout << "N2::N3::Mul(8,9) = " << N2::N3::Mul(8, 9) << endl;
    return 0;
}
*/


/*
#include<iostream>
using namespace std;
int main()
{
    int i = 100;
    //1.左移
    i = i << 1;              
    cout << " i = " << i << endl;
    //2.流插入,自动识别类型
    cout << "Hello World\n" << endl;
    const char* str = "Hello World";
    char ch = 'Y';
    printf(" %s, %d, %c\n",str,i,ch);          //C语言风格打印

    //1.右移
    int x = 100;
    x = x >> 1;
    cout << " x = " << x << endl;

    //2.流提取,自动识别类型
    cout << "请输入 x的值: ";
    cin >>x;
    cout << " x = " << x << endl;
}
*/

//缺省/默认参数
/*
#include<iostream>
using namespace std;

void Func(int a=0)
{
    cout << "a = " << a << endl;
}
//半缺省，从左往右连续传参，不能够跳跃传值，也不能从右往左传值
void Func1(int p1, int p2 = 20, int p3 = 30) {
    cout << "p1 = " << p1 << endl;
    cout << "p2 = " << p2 << endl;
    cout << "p3 = " << p3 << endl<<endl;

}

int main()
{
    Func();                       //不带参数调用，会保留缺省值
    Func(1);                  
    Func1(1, 2, 3);               //
    Func1(1, 2);                  //
    Func1(1);                     //
    //Func1(, 2, );               //不能跳跃调用
    //Func1(, , 3);               //不能从右往左传值
}
*/


//缺省参数的应用场景，定义栈时，灵活多变的扩容
/*
#include"Stack.h"
using namespace std;

int main()
{
    //1.确定要插入100个数据
    Stack st1;
    StackInit(&st1,100);
    //2.确定要插入10个数据
    Stack st2;
    StackInit(&st2, 10);
    //3.不知道要插入多少数据
    Stack st1;
    StackInit(&st1, 100);
}
*/


